﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZHDJ.Core.Util;
using ZHDJ.Data.Models.Center;
using ZHDJ.WebPage;

namespace ZHDJ.Web.Portal.MeetingLecture
{
    public partial class CoursesMeetingDetail : PortalPage
    {
        public string DetailID
        {
            get
            {
                return this.Request["ID"] ?? "";
            }
        }

        public string Category
        {
            get
            {
                return this.Request["Category"] ?? "";
            }
        }
        public string BranchID
        {
            get
            {
                try {
                    if (DataSource.Rows.Count > 0)
                        return DataSource.Rows[0]["BranchID"].ToString();
                } catch (Exception ex ) {
                    return this.Request["BranchID"] ?? "";
                }
                
                return "";
            }
        }
        public DataTable DataSource
        {
            get
            {
                return PartyMeetingLecture.GetDetail(this.DetailID, this.Category);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        public string GetMeetingMember(string id)
        {
            DataTable dt = PartyMeetingLectureMember.GetGridData(id, "1");
            List<string> list = new List<string>();

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    list.Add(Convert.ToString(item["UserName"]));
                }

                return string.Join(",", list);
            }
            else
            {
                return "";
            }
        }

        public string GetTime(DataRow dr)
        {
            var rs = "";
            string beginTime = Convert.ToString(dr["BeginTime"]);
            string endTime = Convert.ToString(dr["EndTime"]);
            if (ValidateHelper.IsDateTime(beginTime))
            {
                rs = Convert.ToDateTime(beginTime).ToString("yyyy-MM-dd HH:mm");
            }

            if (ValidateHelper.IsDateTime(endTime))
            {
                rs +="至"+ Convert.ToDateTime(beginTime).ToString("yyyy-MM-dd HH:mm");
            }
            return rs;
        }
    }
}